package com.guoranhao.tool.utils;

import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

public class PropertiesUtils {
    private static Properties prop = new Properties();

    public PropertiesUtils() {
    }

    public static String getValue(String key) {
        String value = null;
        if(key != null) {
            value = prop.getProperty(key);
        }

        if(value != null) {
            value = value.trim();
        }

        return value;
    }

    static {
        try {
            prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("common.properties"));
            Set exp = prop.keySet();

            String key;
            String value;
            for(Iterator it = exp.iterator(); it.hasNext(); prop.setProperty(key, value)) {
                key = (String)it.next();
                value = null;

                try {
                    value = new String(prop.getProperty(key).getBytes("ISO-8859-1"), "utf-8");
                } catch (UnsupportedEncodingException var5) {
                    value = prop.getProperty(key);
                }
            }

        } catch (Exception var6) {
            throw new RuntimeException(var6);
        }
    }
}
